//
// Created by dwx on 2024/1/30.
//

#ifndef SIMPLEFOC_BSP_SENSOR_H
#define SIMPLEFOC_BSP_SENSOR_H
#ifdef __cplusplus
extern "C" {
#endif

#include "main.h"
#include "spi.h"

typedef struct {
    long cpr;
    long velocity_calc_timestamp;
    long angle_data_prev;
    long angle_prev;
    float full_rotation_offset;
}ENCODER_S;

#define  AS5600_CPR       4096       //12bit
#define  AS5047P_CPR      16384      //14bit
#define  TLE5012B_CPR     32768      //15bit
#define  MA730_CPR        65536      //14bit,左对齐,低两位补0,所以是65536
#define  MT6701_CPR       65536      //14bit,左对齐,低两位补0,所以是65536
extern ENCODER_S E0;
extern uint16_t ReadMT6701(void);
extern float getVelocity(ENCODER_S *E);
extern float getAngle(ENCODER_S *E);
extern uint16_t getRawCount(void);
extern void MagneticSensor_Init(void);
#ifdef __cplusplus
}
#endif
#endif //SIMPLEFOC_BSP_SENSOR_H
